/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cooperativa.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.cooperativa.entities.Transaccion;
import org.cooperativa.entities.TransaccionDetalle;

/**
 *
 * @author giovanny
 */
@Stateless
public class TransaccionDetalleFacade extends AbstractFacade<TransaccionDetalle> {
    @PersistenceContext(unitName = "CooperativaPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public TransaccionDetalleFacade() {
        super(TransaccionDetalle.class);
    }
    
    /***El siguiente metodo sirve para recuperar la lista de detalle de la transaccion***/
    public List<TransaccionDetalle> obtenerDetalleList(Transaccion idTransaccion) {
        List<TransaccionDetalle> resultList;
        
        try{
        Query q = em.createNamedQuery("TransaccionDetalle.findByTransaccionId");
        q.setParameter("idTransaccion", idTransaccion);
        
        resultList = (List<TransaccionDetalle>) q.getResultList();
                        
        return resultList;
        }
        catch(Exception e){
            
        return null;
        }
    }
    
}
